package data;

public class Point implements Comparable<Point> {
	private int x;
	private int y;

	private int f;
	private int g;
	private int h;

	private Point parentPoint;

	public Point(int x, int y) {
		this.x = x;
		this.y = y;
		this.g = 0;
	}

	public void CalcF() {
		this.f = this.g + this.h;
	}

	public void CalcF(Point goal) {
//		int distance = (int) Math.pow(goal.getX() - x, 2) + (int) Math.pow(goal.getY() - y, 2);
		this.f = this.g + this.h;
	}

	public void CalcH(Point p) {
		this.h = (Math.abs(p.getX() - this.x) + Math.abs(p.getY() - this.y)) * GrapData.H_RADIO;
		// int h_diagonal = Math.min(Math.abs(this.x - p.x), Math.abs(this.y -
		// p.y));
		// int h_straight = (Math.abs(this.x - p.x) + Math.abs(this.y - p.y));
		// this.h = gDiagonal * h_diagonal + gSide * (h_straight -
		// 2*h_diagonal);
	}

	@Override
	public int compareTo(Point o) {
		return this.f - o.f;
	}

	public boolean equals(Object o) {
		Point p = (Point) o;
		return this.x == p.x && this.y == p.y;
	}

	@Override
	public int hashCode() {
		return x * y;
	}

	@Override
	public String toString() {
		return x + "," + y + " f:" + f;
	}

	public int getX() {
		return x;
	}

	public void setX(int x) {
		this.x = x;
	}

	public int getY() {
		return y;
	}

	public void setY(int y) {
		this.y = y;
	}

	public int getF() {
		return f;
	}

	public void setF(int f) {
		this.f = f;
	}

	public int getG() {
		return g;
	}

	public void setG(int g) {
		this.g = g;
	}

	public int getH() {
		return h;
	}

	public void setH(int h) {
		this.h = h;
	}

	public Point getParentPoint() {
		return parentPoint;
	}

	public void setParentPoint(Point parentPoint) {
		this.parentPoint = parentPoint;
	}

}
